<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <!-- 1.导入Vue包 -->
    <script src="lib/vue-2.4.0.js"></script>
</head>

<body>

    <!-- 创建一个要控制的区域 -->
    <div id="app">
        <input type="button" value="浪起来" @click='lang'>
        <input type="button" value="低调" @click='stop'>
        <h4 v-cloak>{{msg}}</h4>
    </div>

    <script>
        var vm = new Vue({
            el: '#app',
            data: {
                msg: '猥琐发育，别浪~~！',
                intervalId: null
            },
            methods: {
                lang() {
                    // console.log(this.msg)
                    // var this = this

                    if (this.intervalId != null) return;

                    this.intervalId = setInterval(() => {
                        /* 获取到头的第一个字符 */
                        var start = this.msg.substring(0, 1)
                        /* 获取到后面的所有字符 */
                        var end = this.msg.substring(1)
                        /* 重新拼接得到新的字符串， 并赋值*/
                        this.msg = end + start
                    }, 400)
                },
                stop() { //停止定时器
                    clearInterval(this.intervalId)
                    this.intervalId = null
                }
            }
        })
    </script>
</body>

</html>